//
//  RDConfiguration.m
//  readApp
//
//  Created by 飞猪 on 2018/8/16.
//  Copyright © 2018年 😝😝😝😝😝. All rights reserved.
//

#import "RDConfiguration.h"

@implementation RDConfiguration

- (instancetype)init {
  self = [super init];
  if (self) {
    _contentFrame = CGRectZero;
    _lineHeightMutiplier = 2;
    _fontSize = 17.f;
    
    CGFloat safeAreaTopHeight = kScreenHeight == 812.0 ? 24 : 0;
    CGFloat safeAreaBottomHeight = kScreenHeight == 812.0 ? 34 : 0;
    _contentFrame = CGRectMake(18, 18 + safeAreaTopHeight, kScreenHeight - 36, kScreenHeight - 36 - safeAreaTopHeight - safeAreaBottomHeight);
    
    _charColor = KDayColor;
    
    _fontName = [[NSUserDefaults standardUserDefaults] objectForKey:@"fontName"];
                          
  }
  return self;
}

- (void)setReaderBGImage:(UIImage *)readerBGImage {
  _readerBGImage = readerBGImage;
  
  if (self.readerBGImageChanged) {
    self.readerBGImageChanged(_readerBGImage);
  }
}

- (void)setCharColor:(UIColor *)charColor {
  
  if (!CGColorEqualToColor(_charColor.CGColor, charColor.CGColor)) {
    _charColor = charColor;
    
    if (self.charColorChanged) {
      self.charColorChanged(_charColor);
    }
  }
  
}

- (void)setFontName:(NSString *)fontName {
  if (![fontName isEqualToString:_fontName]) {
    _fontName = fontName;
    
    if (self.fontNameChanged) {
      self.fontNameChanged(_fontName);
    }
  }
}

@end
